#include<iostream>
#include<windows.h>
using namespace std;

int main()
{
	HANDLE hFile = CreateFile(L"\\\\*\\mailslot\\MySlot",
								GENERIC_WRITE ,
								FILE_SHARE_READ,
								NULL,
								OPEN_EXISTING,
								NULL, NULL
								);
/*
	\\.\mailslot\name	Retrieves a client handle to a local mailslot.
	\\computername\mailslot\name	Retrieves a client handle to a remote mailslot.
	\\domainname\mailslot\name	Retrieves a client handle to all mailslots with the specified name in the specified domain.
	\\*\mailslot\name	Retrieves a client handle to all mailslots with the specified name in the system's primary domain.
*/
	char buffer[255];
	DWORD size;
	while(1)
	{
	cout << "Enter line : ";
	cin.getline(buffer, 80);
	
	if(WriteFile(hFile, buffer, strlen(buffer) + 1, &size, NULL))
	//while(WriteFile(hFile, buffer, strlen(buffer) + 1, &size, NULL))
		cout<<"Buffer is writed!!!";
	}
	
	if(ReadFile(hFile, buffer, 255, &size, NULL))
		cout << "Answer : " << buffer << endl;

	
	return 0;
}